﻿#if USE_UNI_LUA
using LuaAPI = UniLua.Lua;
using RealStatePtr = UniLua.ILuaState;
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
#else
using LuaAPI = XLua.LuaDLL.Lua;
using RealStatePtr = System.IntPtr;
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
#endif

using XLua;
using System.Collections.Generic;


namespace XLua.CSObjectWrap
{
    using Utils = XLua.Utils;
    public class LuaEventFrameworkWrap 
    {
        public static void __Register(RealStatePtr L)
        {
			ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
			System.Type type = typeof(LuaEventFramework);
			Utils.BeginObjectRegister(type, L, translator, 0, 0, 0, 0);
			
			
			
			
			
			
			Utils.EndObjectRegister(type, L, translator, null, null,
			    null, null, null);

		    Utils.BeginClassRegister(type, L, __CreateInstance, 8, 2, 0);
			Utils.RegisterFunc(L, Utils.CLS_IDX, "Count", _m_Count_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Check", _m_Check_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Subscribe", _m_Subscribe_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Unsubscribe", _m_Unsubscribe_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "SetDefaultHandler", _m_SetDefaultHandler_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Fire", _m_Fire_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "FireNow", _m_FireNow_xlua_st_);
            
			
            
			Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "EventHandlerCount", _g_get_EventHandlerCount);
            Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "EventCount", _g_get_EventCount);
            
			
			
			Utils.EndClassRegister(type, L, translator);
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __CreateInstance(RealStatePtr L)
        {
            return LuaAPI.luaL_error(L, "LuaEventFramework does not have a constructor!");
        }
        
		
        
		
        
        
        
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Count_xlua_st_(RealStatePtr L)
        {
		    try {
            
            
            
                
                {
                    int _id = LuaAPI.xlua_tointeger(L, 1);
                    
                        var gen_ret = LuaEventFramework.Count( _id );
                        LuaAPI.xlua_pushinteger(L, gen_ret);
                    
                    
                    
                    return 1;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Check_xlua_st_(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
            
                
                {
                    int _id = LuaAPI.xlua_tointeger(L, 1);
                    System.EventHandler<GameFramework.Event.GameEventArgs> _handler = translator.GetDelegate<System.EventHandler<GameFramework.Event.GameEventArgs>>(L, 2);
                    
                        var gen_ret = LuaEventFramework.Check( _id, _handler );
                        LuaAPI.lua_pushboolean(L, gen_ret);
                    
                    
                    
                    return 1;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Subscribe_xlua_st_(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
            
                
                {
                    int _id = LuaAPI.xlua_tointeger(L, 1);
                    System.EventHandler<GameFramework.Event.GameEventArgs> _handler = translator.GetDelegate<System.EventHandler<GameFramework.Event.GameEventArgs>>(L, 2);
                    
                    LuaEventFramework.Subscribe( _id, _handler );
                    
                    
                    
                    return 0;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Unsubscribe_xlua_st_(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
            
                
                {
                    int _id = LuaAPI.xlua_tointeger(L, 1);
                    System.EventHandler<GameFramework.Event.GameEventArgs> _handler = translator.GetDelegate<System.EventHandler<GameFramework.Event.GameEventArgs>>(L, 2);
                    
                    LuaEventFramework.Unsubscribe( _id, _handler );
                    
                    
                    
                    return 0;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_SetDefaultHandler_xlua_st_(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
            
                
                {
                    System.EventHandler<GameFramework.Event.GameEventArgs> _handler = translator.GetDelegate<System.EventHandler<GameFramework.Event.GameEventArgs>>(L, 1);
                    
                    LuaEventFramework.SetDefaultHandler( _handler );
                    
                    
                    
                    return 0;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Fire_xlua_st_(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
            
                
                {
                    object _sender = translator.GetObject(L, 1, typeof(object));
                    GameFramework.Event.GameEventArgs _e = (GameFramework.Event.GameEventArgs)translator.GetObject(L, 2, typeof(GameFramework.Event.GameEventArgs));
                    
                    LuaEventFramework.Fire( _sender, _e );
                    
                    
                    
                    return 0;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_FireNow_xlua_st_(RealStatePtr L)
        {
		    try {
            
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            
            
            
                
                {
                    object _sender = translator.GetObject(L, 1, typeof(object));
                    GameFramework.Event.GameEventArgs _e = (GameFramework.Event.GameEventArgs)translator.GetObject(L, 2, typeof(GameFramework.Event.GameEventArgs));
                    
                    LuaEventFramework.FireNow( _sender, _e );
                    
                    
                    
                    return 0;
                }
                
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            
        }
        
        
        
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_EventHandlerCount(RealStatePtr L)
        {
		    try {
            
			    LuaAPI.xlua_pushinteger(L, LuaEventFramework.EventHandlerCount);
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }
        
        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_EventCount(RealStatePtr L)
        {
		    try {
            
			    LuaAPI.xlua_pushinteger(L, LuaEventFramework.EventCount);
            } catch(System.Exception gen_e) {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }
        
        
        
		
		
		
		
    }
}
